/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.raitcon.hibernate.backbean;
import com.raitcon.hibernate.bean.Anio;
import com.raitcon.hibernate.db.AnioDB;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;

/**
 *
 * @author Mike
 */
@ManagedBean(name="anioBean")
@RequestScoped
public class AnioBean implements Serializable {
    
   protected static Logger log = Logger.getLogger(AnioBean.class); 
   private static  final  long serialVersionUID=-2377612760546575074L;
   private String currentItem = "";
   private List<SelectItem> anioList = new ArrayList<SelectItem>();
   private String selectedAnio = "0";
   
   @PostConstruct
   protected void init(){
       log.debug("init...anioBean");
       AnioDB anioDB=new AnioDB();
        List<Anio> anioLst=anioDB.getAnioAll();
        SelectItem item = new SelectItem("0", "--Selecciona Año--");
         getAnioList().add(item);
        for(Anio g:anioLst){
            item = new SelectItem(g.getIdAnio(),String.valueOf(g.getDescripcion()));
            getAnioList().add(item);
        }
      
   }

    /**
     * @return the selectedAnio
     */
    public String getSelectedAnio() {
        return selectedAnio;
    }

    /**
     * @param selectedAnio the selectedAnio to set
     */
    public void setSelectedAnio(String selectedAnio) {
        this.selectedAnio = selectedAnio;
    }

    /**
     * @return the anioList
     */
    public List<SelectItem> getAnioList() {
        return anioList;
    }

    /**
     * @param anioList the anioList to set
     */
    public void setAnioList(List<SelectItem> anioList) {
        this.anioList = anioList;
    }
    
}
